var app = getApp()
Page({
    data: {
        code: 0
    },

    onLoad() {
        this.getdata()
    },

    getdata() {
        var that = this
        app.api_request('?c=contact','GET','').then(function (res) {
            if (res) {
                that.setData({
                    code: 1,
                    pagedata: res,
                })
                tt.setNavigationBarTitle({
                    title: res.appTitle
                })
            }
        })
    },

    callphone(e) {
        const { phone } = e.currentTarget.dataset
        tt.makePhoneCall({
            phoneNumber: phone,
            success(res) {
                console.log("调用成功", res.errMsg)
            },
            fail(res) {
                console.log("调用失败", res.errMsg)
            }
        })
    },

    getLocation(e) {
        const { latitude,longitude,storename,address } = e.currentTarget.dataset
        // console.log(latitude)
        // console.log(longitude)
        // console.log(storename)
        // console.log(address)
        tt.getLocation({
            isHighAccuracy: true, // 开启地图精准定位
            type: 'gcj02', //gcj02 / wgs84
            success: function (res) {
                tt.openLocation({
                    latitude: latitude,
                    longitude: longitude,
                    name: storename,
                    address: address
                })
            },
            fail: function (res) {
                // console.log(res)
                tt.showToast({
                    title: '请开启手机位置信息',
                    icon: 'none',
                    duration: 2000
                })
            }
        })
    },

    onShareAppMessage: function () {
        var that = this
        return {
            title: that.data.pagedata.appTitle,
            desc: that.data.pagedata.appDesc,
            path: '/pages/contact/index'
        }
    },
})